import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:largefriends/res/lf_color.dart';
import 'package:largefriends/res/lf_fonts.dart';
import 'package:largefriends/res/lf_text_style.dart';

class LfButton extends StatefulWidget {
  final bool enabled;
  final String text;
  final Function() onPress;
  final Color? enableColor;
  final Color? disableColor;
  final Color? textColor;
  const LfButton({
    super.key,
    required this.enabled,
    required this.text,
    required this.onPress,
    this.enableColor,
    this.disableColor,
    this.textColor,
  });

  @override
  State<LfButton> createState() => _LfButtonState();
}

class _LfButtonState extends State<LfButton> {
  @override
  Widget build(BuildContext context) {
    return InkWell(
      onTap: () {
        if (widget.enabled) {
          widget.onPress.call();
        }
      },
      splashColor: Colors.transparent,
      highlightColor: Colors.transparent,
      child: Container(
        margin: EdgeInsets.symmetric(
          horizontal: 20.w,
        ),
        width: double.infinity,
        padding: EdgeInsets.symmetric(vertical: 15.h),
        alignment: Alignment.center,
        decoration: BoxDecoration(
            gradient: LinearGradient(
                colors: widget.enabled
                    ? [
                        colorFF007F,
                        colorBF00FF,
                      ]
                    : [color8F8F8F, color8F8F8F],
                begin: const Alignment(-0.9, -1),
                end: const Alignment(0.9, 1)),
            borderRadius: BorderRadius.all(Radius.circular(40.h))),
        child: Text(
          widget.text,
          style: lfTextStyle(
            sp: 16.sp,
            color: widget.enabled? Colors.white:Colors.white54,
            fontFamily: fontBold,
          ),
        ),
      ),
    );
  }
}
